import 'package:card_swiper/card_swiper.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:lcapp/api/interface/home_api.dart';
import 'package:lcapp/api/interface/user_api.dart';
import 'package:lcapp/api/request/response_data.dart';
import 'package:lcapp/basic/user_info.dart';
import 'package:lcapp/config/const_config.dart';
import 'package:lcapp/data/media_asset_data_entity.dart';
import 'package:lcapp/data/xian_huo_data_entity.dart';
import 'package:lcapp/model/share/custom_share.dart';
import 'package:lcapp/model/toast/toast.dart';
import 'package:lcapp/page/aMapView/amap_tool.dart';
import 'package:lcapp/page/home/home_share_page.dart';
import 'package:lcapp/page/search/xianhuo_item.dart';
import 'package:lcapp/tools/string_tool.dart';
import 'package:lcapp/widget/asr_app_bar.dart';
import 'package:lcapp/widget/asr_cache_image.dart';
import 'package:lcapp/widget/lc_gesture_detector.dart';
import 'package:url_launcher/url_launcher.dart';


class XianHuoDetailPage extends StatefulWidget {
  final int xid;
  const XianHuoDetailPage({Key? key, required this.xid}) : super(key: key);

  @override
  _XianHuoDetailPageState createState() => _XianHuoDetailPageState();
}

class _XianHuoDetailPageState extends State<XianHuoDetailPage> {

  int swiperIndex = 0;
  int pageNum = 1;
  int pageSize  =10;
  late double disTance;
  XianHuoDataEntity entity = XianHuoDataEntity();
  List<XianHuoDataEntity> xianHuos = [];
  late String location;
  late String region;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    entity.user = XianHuoUserEntity();
    getDetail();
    getXianHuo();
  }
  getDetail()async{
    showLoading();
    ResponseData res = await HomeAPI.getXianDetail(widget.xid);
    hideLoading();
    if(res.code==200){
      entity = XianHuoDataEntity().fromJson(res.data);
      if(entity.address!=null&&entity.address!.isNotEmpty){
        List arr = entity.address!.split(' ');
        print('arr====='+arr.toString());
        if(arr.length>=4){
          location = '${arr[0]??''} ${arr[1]??''} ${arr[2]??''}';
          region = arr[2]??'';
        }else{
          location = entity.address!;
        }
      }
      if(entity.longitude!=null&&entity.latitude!=null&&entity.longitude!.isNotEmpty&&entity.latitude!.isNotEmpty){
        // disTance = AmapTool.getDistance(double.parse(entity.latitude), double.parse(entity.longitude));
      }
    }
    if(mounted){
      setState(() {});
    }
  }

  getXianHuo()async{
    ResponseData res = await HomeAPI.getHotXianHuos();
    if(res.code==200){
      List arr = res.data??[];
      xianHuos.clear();
      for (var element in arr) {
        XianHuoDataEntity entity = XianHuoDataEntity().fromJson(element);
        xianHuos.add(entity);
      }
    }
    if(mounted){setState(() {
    });}
  }



  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: bgColor,
      appBar: AsrAppBar(
        backgroundColor: defaultBarColor,
        barColor: Colors.white,
        titleText: '现货详情',
        actions: [
          GestureDetector(
            onTap: (){
              Navigator.of(context).pushNamed('MinJuBaoPage',arguments: {
                'type':4,
                'entityId':entity.id
              });
            },
            child: Container(
              padding: EdgeInsets.only(right: 30.w),
              color: Colors.transparent,
              child: Image.asset('assets/home/jubao.png',width: 45.w,fit: BoxFit.fitWidth,),
            ),
          )
        ],
      ),
      body: EasyRefresh(
        child: entity==null||entity.id == null ? Container(): SingleChildScrollView(
         child: Column(
           children: [
             Visibility(child: Container(
               width: 1.sw,
               height: 580.w,
               color: Colors.black,
               child: Stack(
                 children: [
                   Swiper(
                     itemCount: entity.images!=null&&entity.images!.isNotEmpty?entity.images!.length:0,
                     autoplay: true,
                     loop: true,
                     onIndexChanged: (index){
                       setState(() {
                         swiperIndex = index;
                       });
                     },
                     itemBuilder: (BuildContext context, int index) {
                       return GestureDetector(
                         onTap: () {
                           List<MediaAssetDataEntity> arr = [];
                           for (var element in entity.images!) {
                             MediaAssetDataEntity imgentity = MediaAssetDataEntity();
                             imgentity.type=1;
                             imgentity.uri = element;
                             arr.add(imgentity);
                           }
                           Navigator.of(context).pushNamed('MediaViewer', arguments: {
                             'assets': arr,
                             'currentIndex': index
                           });
                         },
                         child: ClipRRect(
                           child: ASRCacheImage(width: 1.sw,height: 580.w,image: entity.images!=null&&entity.images!.isNotEmpty?entity.images![index]:'',fit: BoxFit.fitWidth,),
                         ),
                       );
                     },
                   ),
                   Positioned(child: Container(
                     width: 80.w,
                     height: 40.w,
                     alignment: Alignment.center,
                     decoration: BoxDecoration(
                         color:Color.fromRGBO(0, 0, 0, 0.45),
                         borderRadius: BorderRadius.circular(80.w)
                     ),
                     child: Text('${swiperIndex+1}/${entity.images!=null&&entity.images!.isNotEmpty? entity.images!.length:0}',style: TextStyle(
                         color: Colors.white,
                         fontSize: 24.sp
                     ),),
                   ),right: 30.w,bottom: 30.w,)
                 ],
               ),
             ),visible: entity.images!=null&&entity.images!.isNotEmpty,),
             Container(
               color: Colors.white,
               width: 1.sw,
               padding: EdgeInsets.symmetric(horizontal: 30.w,vertical: 40.w),
               child: Column(
                 crossAxisAlignment: CrossAxisAlignment.start,
                 children: [
                   Row(
                     crossAxisAlignment: CrossAxisAlignment.center,
                     children: [
                       RichText(
                         maxLines: 1,
                         softWrap: true,
                         text: TextSpan(
                           text: '￥${entity.price}',
                           style: TextStyle(
                               fontSize: 50.sp,
                               color: const Color(0xffFF1818),
                               fontWeight: FontWeight.w600
                           ),
                           children: <TextSpan>[
                             TextSpan(
                               text: ' ${StringTool.getDWstr(entity.productUnit!)}',
                               style:  TextStyle(
                                 color: Color(0xff666666),
                                 fontSize: 24.sp,
                               ),
                             ),
                           ],
                         ),
                         textAlign: TextAlign.left,
                       ),
                       SizedBox(width: 20.w,),
                       Visibility(child: Container(
                         width: 120.w,
                         height: 45.w,
                         alignment: Alignment.center,
                         decoration: BoxDecoration(
                             color:Color(0xffFFEDE3),
                             borderRadius: BorderRadius.circular(10.w),
                             border: Border.all(color: Color(0xffEB7A38))
                         ),
                         child: Text('可议价',style: TextStyle(
                             color: Color(0xffEB7A38),
                             fontSize: 24.sp
                         ),),
                       ),visible: entity.bargain==1,),
                       Visibility(child: Container(
                         margin: EdgeInsets.only(left: 20.w),
                         width: 120.w,
                         height: 45.w,
                         alignment: Alignment.center,
                         decoration: BoxDecoration(
                             color:Color(0xffFFEDE3),
                             borderRadius: BorderRadius.circular(10.w),
                             border: Border.all(color: Color(0xffEB7A38))
                         ),
                         child: Text('采购',style: TextStyle(
                             color: Color(0xffEB7A38),
                             fontSize: 24.sp
                         ),),
                       ),visible: entity.publishType==1,),
                       Expanded(child: Container()),
                       lcGestureDetector(
                         isLogin:true,
                         onTap: (){
                           SmartDialog.show(
                             alignment: Alignment.bottomCenter,
                             clickMaskDismiss: true,
                             maskColor: Color.fromRGBO(0, 0, 0, 0.5), builder: (BuildContext context) {
                               return HomeSharepage(
                                 contentType: 2,
                                 shareType: 2,
                                 xianHuoDataEntity: entity,
                                 shareUrl: '${BasVueurl}/#/xianhuo?lcID=${userInfo.id}&shareId=${entity.id}',
                                 map: {
                                   'type':2,
                                   'entryId':entity.id
                                 },
                               );
                           },
                           );
                         },
                         child: Container(
                           child: Row(
                             children: [
                               Image.asset('assets/share/share_gray.png',width: 30.w,),
                               SizedBox(width: 10.w,),
                               Text('分享')
                             ],
                           ),
                         ),
                       )
                     ],
                   ),
                   SizedBox(height: 20.w,),
                   Row(
                     children: [
                       Expanded(child: RichText(
                         maxLines: 2,
                         softWrap: true,
                         text: TextSpan(
                           children: [
                             WidgetSpan(child: Container(
                               child: Text('${entity.year}',style: TextStyle(
                                 fontSize: 24.w,
                                 color: Colors.white,
                               ),),
                               margin: EdgeInsets.only(right: 10.w),
                               padding: EdgeInsets.symmetric(vertical: 6.w,horizontal: 16.w),
                               decoration: BoxDecoration(
                                   color: Color(0xffEB6E30),
                                   borderRadius: BorderRadius.circular(6.w)
                               ),
                             )),
                             TextSpan(
                               text: '${entity.name}',
                               style: TextStyle(
                                   fontSize: 34.w,
                                   color: Colors.black,
                                   fontWeight: FontWeight.w600
                               ),
                             ),
                           ],
                         ),
                         textAlign: TextAlign.left,
                       )),
                     ],
                   ),
                   SizedBox(height: 20.w,),
                   Visibility(child: Row(
                     crossAxisAlignment: CrossAxisAlignment.center,
                     children: [
                       Container(
                         child: Image.asset('assets/fabu/fabu_dt.png',width: 40.w,),
                         margin: EdgeInsets.only(right: 20.w),
                       ),
                       Expanded(child: Text('当前距离经营地${disTance}公里',
                         maxLines: 1,
                         style: TextStyle(
                           fontSize: 28.w,
                           color: Colors.black,
                         ),)),
                       Container(
                         child: Text('数量: ${entity.numbers}/吨',style: TextStyle(
                             fontSize: 24.sp,
                             color: Color(0xff666666)
                         ),),
                       )
                     ],
                   ),visible: location!=null&&entity.latitude!=null&&entity.longitude!=null&&disTance!=null),
                   Container(
                     height: 1,
                     margin: EdgeInsets.symmetric(vertical: 30.w),
                     color: Color(0xffE9E8E9),
                   ),
                   Visibility(child:  Row(
                     crossAxisAlignment: CrossAxisAlignment.center,
                     children: [
                       Container(
                         child: Text('经营地址:',
                           maxLines: 1,
                           style: TextStyle(
                               fontSize: 24.w,
                               color: Colors.black,
                               fontWeight: FontWeight.w600
                           ),),
                         width: 120.w,
                       ),
                       Expanded(child: Text('${location}',
                         maxLines: 1,
                         overflow: TextOverflow.ellipsis,
                         style: TextStyle(
                           fontSize: 24.w,
                           color: Colors.black,
                         ),)),
                     ],
                   ),visible: location!=null,),
                   SizedBox(height: 20.w,),
                   Row(
                     crossAxisAlignment: CrossAxisAlignment.center,

                     children: [
                       Container(
                         child: Text('产地:',
                           maxLines: 1,
                           style: TextStyle(
                               fontSize: 24.w,
                               color: Colors.black,
                               fontWeight: FontWeight.w600
                           ),),
                         width: 120.w,
                       ),
                       SizedBox(width: 0.w,),
                       Expanded(child: Text('${entity.production}',
                         style: TextStyle(
                           fontSize: 24.w,
                           color: Colors.black,
                         ),)),
                     ],
                   ),
                   Container(
                     margin: EdgeInsets.only(top: 30.w),
                     alignment: Alignment.center,
                     child: Text('更新时间: ${entity.updateTime}',style: TextStyle(
                       fontSize: 24.sp,
                       color: Color(0xff666666)
                     ),),
                   )
                 ],
               ),
             ),
             Container(
               margin: EdgeInsets.only(top: 40.w),
               color: Colors.white,
               padding: EdgeInsets.all(30.w),
               child: Column(
                 children: [
                   Container(
                     child: Row(
                       children: [
                         ClipRRect(
                           child:ASRCacheImage(image: entity.user?.img??'assets/icon/p_head.png',width: 120.w,height: 120.w,fit: BoxFit.fitWidth,),
                           borderRadius: BorderRadius.circular(120.w),
                         ),
                         Expanded(child: Container(
                           margin: EdgeInsets.symmetric(horizontal: 20.w),
                           height: 120.w,
                           child: Column(
                             mainAxisAlignment: MainAxisAlignment.spaceAround,
                             crossAxisAlignment: CrossAxisAlignment.start,
                             children: [
                               Row(
                                 children: [
                                   RichText(
                                     maxLines: 1,
                                     softWrap: true,
                                     text: TextSpan(
                                       text: '${entity.user?.name}',
                                       style: TextStyle(
                                           fontSize: 30.sp,
                                           color: Colors.black,
                                           fontWeight: FontWeight.w600
                                       ),
                                     ),
                                     textAlign: TextAlign.left,
                                   ),
                                   SizedBox(width: 10.w,),
                                   Visibility(child: Image.asset('assets/min/min_sm.png',height: 30.w,),visible: entity.user?.card==1,),
                                   SizedBox(width: 10.w,),
                                   Visibility(child: Image.asset('assets/min/min_vip.png',height: 30.w,),visible: entity.user?.vip==1,),
                                 ],
                               ),
                               Visibility(child: Container(
                                 child: Row(
                                   children: [
                                     Image.asset('assets/home/smrz_succ.png',height: 26.w,),
                                     SizedBox(width: 10.w,),
                                     Text(entity.user?.realName??'',style: TextStyle(
                                         color: Colors.black,
                                         fontSize: 24.sp,
                                         fontWeight: FontWeight.w400
                                     ),),
                                   ],
                                 ),
                               ),visible: entity.user?.card==1,),
                             ],
                           ),
                         )),
                         GestureDetector(
                           onTap: (){
                             Navigator.of(context).pushNamed('ShopHomePage',arguments: entity.user?.userId);
                           },
                           child: Container(
                             child: Column(
                               children: [
                                 Row(
                                   children: [
                                     Text('查看商家',style: TextStyle(
                                         fontSize: 26.sp,
                                         color: Color(0xffEB6E30),
                                         fontWeight: FontWeight.w600
                                     ),),
                                     Icon(Icons.arrow_forward_ios,size: 30.w,color: Color(0xffEB6E30),),
                                   ],
                                 ),
                                 SizedBox(height: 10.w,),
                                 RichText(
                                   maxLines: 1,
                                   softWrap: true,
                                   text: TextSpan(
                                     children: [
                                       TextSpan(
                                         text: '  已发布${entity.user?.number}条信息',
                                         style:  TextStyle(
                                           color: Color(0xff666666),
                                           fontSize: 24.sp,
                                         ),
                                       ),
                                     ],
                                   ),
                                   textAlign: TextAlign.left,
                                 ),
                               ],
                             ),
                           ),
                         )
                       ],
                     ),
                   ),
                   Container(
                     margin: EdgeInsets.symmetric(vertical: 40.w),
                     child: Visibility(child: Row(
                       crossAxisAlignment: CrossAxisAlignment.center,
                       mainAxisAlignment: MainAxisAlignment.center,
                       children: [
                         Container(
                           height: 2,
                           width: 170.w,
                           color: Color(0xffE9E8E9),
                         ),
                         SizedBox(width: 30.w,),
                         Text('详情描述',style: TextStyle(
                             fontSize: 34.sp,
                             color: Color(0xff1A051D),
                             fontWeight: FontWeight.w400
                         ),),
                         SizedBox(width: 30.w,),
                         Container(
                           height: 2,
                           width: 170.w,
                           color: Color(0xffE9E8E9),
                         ),
                       ],
                     ),visible: entity.images!=null&&entity.images!.isNotEmpty,),
                   ),
                   Container(
                     margin: EdgeInsets.only(bottom: 30.w),
                     alignment: Alignment.centerLeft,
                     child: RichText(
                       softWrap: true,
                       text: TextSpan(
                         text: '',
                         style: TextStyle(
                             fontSize: 28.sp,
                             color: const Color(0xff333333),
                             fontWeight: FontWeight.w500
                         ),
                         children: <TextSpan>[
                           TextSpan(
                             text: entity.description??'',
                             style:  TextStyle(
                               color: Color(0xff666666),
                               fontSize: 26.sp,
                             ),
                           ),
                         ],
                       ),
                       textAlign: TextAlign.left,
                     ),
                   ),
                   ListView.builder(
                       itemCount: entity.images!=null&&entity.images!.isNotEmpty?entity.images!.length:0,
                       shrinkWrap: true,
                       physics: NeverScrollableScrollPhysics(),
                       itemBuilder: (context,index){
                         return Container(
                           margin: EdgeInsets.only(bottom: 20.w),
                           child: ASRCacheImage(
                             image: entity.images![index],
                           ),
                         );
                       })
                 ],
               ),
             ),
             Container(
               margin: EdgeInsets.symmetric(vertical: 30.w),
               padding: EdgeInsets.symmetric(horizontal: 30.w),
               child: Row(
                 children: [
                   Container(width: 5,height: 50.w,color: Color(0xffFF7916),),
                   SizedBox(width: 20.w,),
                   Text('为您推荐',style: TextStyle(
                       color: Colors.black,
                       fontWeight: FontWeight.w600,
                       fontSize: 40.sp
                   ),),
                 ],
               ),
             ),
             AlignedGridView.count(
               padding: EdgeInsets.zero,
               itemCount: xianHuos.length,
               crossAxisCount: 2,
               shrinkWrap: true,
               physics: NeverScrollableScrollPhysics(),
               crossAxisSpacing: 10.w,
               mainAxisSpacing: 10.w,
               itemBuilder: (context,index){
                 return XianHuoItem(entity: xianHuos[index], chooseFun: (){},);
               },
             )
           ],
         )
        ),
      ),
      bottomNavigationBar: entity==null||entity.id == null ? Container(): Container(
        padding: EdgeInsets.only(bottom: 20.w),
        height: 120.w+20.w,
        // color: Colors.white,
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            Container(
              decoration: BoxDecoration(
                color: Colors.white,
                boxShadow: [
                  BoxShadow(
                    color: Colors.black.withOpacity(0.1),
                    blurRadius: 10,
                  ),
                ],
              ),
              child: Row(
                children: [
                  lcGestureDetector(
                    isLogin: true,
                    onTap: ()async{
                      showLoading();
                      ResponseData res = await UserAPI.followUser(entity.user!.userId!);
                      hideLoading();
                      if(res.code==200){
                        setState(() {
                          if(entity.user?.attentionState==1){
                            entity.user?.attentionState=0;
                            showToast('已取消关注');
                          }else{
                            showToast('已关注');
                            entity.user?.attentionState=1;
                          }
                        });
                      }
                    },
                    child: Container(
                      alignment: Alignment.center,
                      width: 0.3.sw-1,
                      height: 90.w,
                      decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.only(topLeft: Radius.circular(10.w),bottomLeft: Radius.circular(10.w))
                      ),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Image.asset('assets/xh/xh_guanzhu.png',width: 30.w,),
                          SizedBox(width: 10.w,),
                          Text(entity.user?.attentionState==1?'已关注商户':'关注商户',style: TextStyle(
                              color: Color(0xff727272),
                              fontSize: 26.sp
                          ),)
                        ],
                      ),
                    ),
                  ),
                  Container(
                    height: 50.w,
                    width: 1,
                    color: Color(0xffE9E8E9),
                  ),
                  lcGestureDetector(
                    isLogin: true,
                    onTap: (){
                      // CustomShare().WXChatService();
                    },
                    child: Container(
                      alignment: Alignment.center,
                      color: Colors.white,
                      width: 0.3.sw,
                      height: 90.w,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Image.asset('assets/slider/slider_kefu.png',width: 30.w,),
                          SizedBox(width: 10.w,),
                          Text('在线客服',style: TextStyle(
                              color: Color(0xff727272),
                              fontSize: 26.sp
                          ),)
                        ],
                      ),
                    ),
                  )
                ],
              ),
            ),
            lcGestureDetector(
              isLogin: true,
              onTap: (){
                if(userInfo.vip!=1){
                  SmartDialog.show(
                    alignment: Alignment.center,
                    clickMaskDismiss: true,
                    maskColor: Color.fromRGBO(0, 0, 0, 0.5), builder: (BuildContext context) {
                      return  Container(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.end,
                          children: [
                            Expanded(child: Container()),
                            Container(
                              child: Column(
                                children: [
                                  Container(
                                    child: Text('您还不是会员',style: TextStyle(
                                        color: Colors.black,
                                        fontSize: 35.sp,
                                        fontWeight: FontWeight.w700
                                    ),),
                                    margin: EdgeInsets.only(bottom: 20.w),
                                  ),
                                  Container(
                                    child: Text('请开通后查看',style: TextStyle(
                                        color: Color(0xff242424),
                                        fontSize: 30.sp,
                                        fontWeight: FontWeight.w500
                                    ),),
                                  ),
                                  Container(
                                    margin: EdgeInsets.symmetric(vertical: 40.w,horizontal: 0.w),
                                    height: 1,
                                    color: Colors.grey,
                                  ),
                                  GestureDetector(
                                    onTap: (){
                                      SmartDialog.dismiss();
                                      Navigator.of(context).pushNamed("MinVipPage").then((value){
                                        refreshUserInfo();
                                      });
                                    },
                                    child: Container(
                                      // padding: EdgeInsets.symmetric(horizontal: 60.w),
                                      child: Row(
                                        children: [
                                          Expanded(child: Text('开通会员',textAlign: TextAlign.left,style: TextStyle(
                                              color: Color(0xff232323),
                                              fontSize: 30.sp,
                                              fontWeight: FontWeight.w600
                                          ),)),
                                          Icon(Icons.arrow_forward_ios,size: 30.sp,)
                                        ],
                                      ),
                                    ),
                                  ),
                                  GestureDetector(
                                    onTap: (){
                                      SmartDialog.dismiss();
                                    },
                                    child: Container(
                                      width: 1.sw-120.w,
                                      height: 90.w,
                                      alignment: Alignment.center,
                                      margin: EdgeInsets.only(top: 50.w),
                                      decoration: BoxDecoration(
                                          color: Color(0xffEBEBEB),
                                          borderRadius: BorderRadius.circular(10.w)
                                      ),
                                      child: Text('取消',style: TextStyle(
                                          color: Color(0xff232323),
                                          fontSize: 30.sp,
                                          fontWeight: FontWeight.w500
                                      ),),
                                    ),
                                  )
                                ],
                              ),
                              decoration: BoxDecoration(
                                  color: Colors.white,
                                  borderRadius: BorderRadius.only(topLeft: Radius.circular(15.w),topRight: Radius.circular(15.w))
                              ),
                              padding: EdgeInsets.only(left: 60.w,right: 60.w,top: 30.w,bottom: 20.w+ScreenUtil().bottomBarHeight),
                            )
                          ],
                        ),
                      );
                  },
                  );
                  return;
                }else if(entity.user?.vip!=1){
                  SmartDialog.show(
                    alignment: Alignment.center,
                    clickMaskDismiss: true,
                    maskColor: Color.fromRGBO(0, 0, 0, 0.5), builder: (BuildContext context) {
                      return Container(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.end,
                          children: [
                            Expanded(child: Container()),
                            Container(
                              child: Column(
                                children: [
                                  Container(
                                    child: Text('对方暂时还不是会员',style: TextStyle(
                                        color: Colors.black,
                                        fontSize: 35.sp,
                                        fontWeight: FontWeight.w700
                                    ),),
                                    margin: EdgeInsets.only(bottom: 20.w),
                                  ),
                                  Container(
                                    child: Text('即将给对方发送邀请短信：',style: TextStyle(
                                        color: Color(0xff242424),
                                        fontSize: 30.sp,
                                        fontWeight: FontWeight.w500
                                    ),),
                                  ),
                                  Container(
                                    margin: EdgeInsets.symmetric(vertical: 40.w,horizontal: 0.w),
                                    height: 1,
                                    color: Colors.grey,
                                  ),
                                  GestureDetector(
                                    onTap: ()async{
                                      ResponseData res = await HomeAPI.sendMsgToShop(entity.user!.phone!);
                                      if(res.code==200){
                                        showToast('发送成功');
                                        SmartDialog.dismiss();
                                      }
                                    },
                                    child: Container(
                                      child: Row(
                                        children: [
                                          Expanded(child: Text('${userInfo.addressRegin??''}${userInfo.name??''}，对您的货物有意向，邀您开通会员',textAlign: TextAlign.left,style: TextStyle(
                                              color: Color(0xff232323),
                                              fontSize: 30.sp,
                                              fontWeight: FontWeight.w600
                                          ),)),
                                          SizedBox(width: 50.w,),
                                          Image.asset('assets/home/send_mail.png',width: 60.w,)
                                        ],
                                      ),
                                    ),
                                  ),
                                  GestureDetector(
                                    onTap: (){
                                      SmartDialog.dismiss();
                                    },
                                    child: Container(
                                      width: 1.sw-120.w,
                                      height: 90.w,
                                      alignment: Alignment.center,
                                      margin: EdgeInsets.only(top: 50.w),
                                      decoration: BoxDecoration(
                                          color: Color(0xffEBEBEB),
                                          borderRadius: BorderRadius.circular(10.w)
                                      ),
                                      child: Text('取消',style: TextStyle(
                                          color: Color(0xff232323),
                                          fontSize: 30.sp,
                                          fontWeight: FontWeight.w500
                                      ),),
                                    ),
                                  )
                                ],
                              ),
                              decoration: BoxDecoration(
                                  color: Colors.white,
                                  borderRadius: BorderRadius.only(topLeft: Radius.circular(15.w),topRight: Radius.circular(15.w))
                              ),
                              padding: EdgeInsets.only(left: 60.w,right: 60.w,top: 30.w,bottom: 20.w+ScreenUtil().bottomBarHeight),
                            )
                          ],
                        ),
                      );
                  },
                  );
                  return;
                }
                launchUrl(Uri.parse('tel:${entity.user?.phone}'));
              },
              child: Container(
                width: 0.4.sw,
                height: 110.w,
                alignment: Alignment.center,
                decoration:  BoxDecoration(
                    borderRadius: BorderRadius.only(topLeft: Radius.circular(10.w),bottomLeft: Radius.circular(10.w)),
                    gradient: LinearGradient(
                      colors: [
                        Color(0xffF6A456),
                        Color(0xffF1793C),
                      ],
                      begin: Alignment.topCenter,
                      end: Alignment.bottomCenter,
                    )
                ),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Icon(Icons.add_call,color: Colors.white,size: 40.w,),
                    SizedBox(width: 10.w,),
                    Text('联系商家',style: TextStyle(
                        color: Colors.white,
                        fontSize: 26.sp
                    ),),
                  ],
                ),
              )
            ),
          ],
        ),
      ),
    );
  }
}
